package testcase.validationtest;

import validation.Type;
import validation.Pair;
import card.*;
import junit.framework.TestCase;

public class PairTest extends TestCase {
	private Type pairType;
	private Cardset cardset;
	/**
	* Sets up the test fixture.
	*
	* Called before every test case method.
	*/
	public void setUp() { 
		cardset = new Cardset(2);
		pairType = Pair.getInstance();
	}
	
	/**
	* Tears down the test fixture.
	*
	* Called after every test case method.
	*/
	public void tearDown() { 
		pairType.clear();
		pairType = null;
	}
	
	//Test case 1
	public void testForCorrectPair_1() {
		cardset.add(new Card('h', '3'));
		cardset.add(new Card('s', '3'));
		Type type = pairType.identify(cardset);
		assertEquals(type, pairType);
	}
	
	//Test case 2
	public void testForCorrectPair_2() {
		cardset.add(new Card('d', '9'));
		cardset.add(new Card('c', '9'));
		Type type = pairType.identify(cardset);
		assertEquals(type, pairType);
	}
	
	//Test case 3
	public void testForIncorrectPair_1() {
		cardset.add(new Card('c', 'X')); 
		cardset.add(new Card('d', '8'));
		Type type = pairType.identify(cardset);
		assertEquals(type, null);
	}
	
	//Test case 4
	public void testForIncorrectPair_2() {
		cardset.add(new Card('c', '5'));
		cardset.add(new Card('s', 'A'));
		Type type = pairType.identify(cardset);
		assertEquals(type, null);
	}
	
	public void testForIncorrectPair_3() {
		cardset.add(new Card('c', 'R'));
		cardset.add(new Card('s', 'B'));
		Type type = pairType.identify(cardset);
		assertEquals(type, null);
	}
	
	//Test case 5
	public void testForNotAPair_1() {
		cardset.add(new Card('d', 'R'));
		Type type = pairType.identify(cardset);
		assertEquals(type, null);
	}
	
	//Test case 6
	public void testForNotAPair_2() {
		cardset.add(new Card('d', 'R'));
		cardset.add(new Card('c', 'R'));
		cardset.add(new Card('s', 'R'));
		Type type = pairType.identify(cardset);
		assertEquals(type, null);
	}
	
	//Test case 7
	public void test5IsNotPriorTo7() {
		cardset.add(new Card('h', '5'));
		cardset.add(new Card('s', '5'));
		Cardset testHand = new Cardset(2);		
		testHand.add(new Card('s', '7'));
		testHand.add(new Card('c', '7'));
		pairType.lessPriorityThan(cardset);
		boolean result = pairType.lessPriorityThan(testHand);
		assertEquals(result, true);
	}	
	
	public void testJIsNotPriorToA() {
		cardset.add(new Card('c', 'J'));
		cardset.add(new Card('s', 'J'));
		Cardset testHand = new Cardset(2);		
		testHand.add(new Card('h', 'A'));
		testHand.add(new Card('c', 'A'));
		pairType.lessPriorityThan(cardset);
		boolean result = pairType.lessPriorityThan(testHand);
		assertEquals(result, true);
	}	
	
	public void test6IsNotPriorTo3() {
		cardset.add(new Card('c', '6'));
		cardset.add(new Card('s', '6'));
		Cardset testHand = new Cardset(2);		
		testHand.add(new Card('h', '3'));
		testHand.add(new Card('c', '3'));
		pairType.lessPriorityThan(cardset);
		boolean result = pairType.lessPriorityThan(testHand);
		assertEquals(result, false);
	}	
	
	public void testXIsNotPriorTo8() {
		cardset.add(new Card('c', 'X'));
		cardset.add(new Card('s', 'X'));
		Cardset testHand = new Cardset(2);		
		testHand.add(new Card('h', '8'));
		testHand.add(new Card('c', '8'));
		pairType.lessPriorityThan(cardset);
		boolean result = pairType.lessPriorityThan(testHand);
		assertEquals(result, false);
	}	
	
	public void test4IsNotPriorTo4() {
		cardset.add(new Card('c', '4'));
		cardset.add(new Card('s', '4'));
		Cardset testHand = new Cardset(2);		
		testHand.add(new Card('h', '4'));
		testHand.add(new Card('d', '4'));
		pairType.lessPriorityThan(cardset);
		boolean result = pairType.lessPriorityThan(testHand);
		assertEquals(result, false);
	}	
}
